package com.chinasoft.ui;

import com.chinasoft.listener.ExitButtonListener;
import com.chinasoft.listener.StartButtonListener;

import javax.swing.*;
import java.awt.*;

/**
 * @author 中软zhang
 * @create 2023-07-25 16:35
 */
public class FirstView {
    JFrame frame = new JFrame("this is first windows");

    public FirstView() {
        frame.setLocation(100, 100);
        frame.setSize(815, 655);
        frame.setTitle("骑士夺宝");
        frame.setIconImage(Toolkit.getDefaultToolkit().getImage(TestWindow.class.getResource("/image/person01.png")));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // 面板对象
        Container pane = frame.getContentPane();
        pane.setLayout(null);

        // 退出按钮
        JLabel lblExit = new JLabel("New label");
        lblExit.setIcon(new ImageIcon(FirstView.class.getResource("/image/exit-bt01.png")));
        lblExit.setBounds(304, 358, 186, 42);
        lblExit.addMouseListener(new ExitButtonListener());
        pane.add(lblExit);

        // 启动 按钮
        JLabel lblStart = new JLabel("New label");
        lblStart.setIcon(new ImageIcon(FirstView.class.getResource("/image/start02.png")));
        lblStart.setBounds(304, 258, 186, 42);
        lblStart.addMouseListener(new StartButtonListener(frame));
        pane.add(lblStart);

        JLabel lblMainIcon = new JLabel("New label");
        lblMainIcon.setIcon(new ImageIcon(FirstView.class.getResource("/image/2.png")));
        lblMainIcon.setBounds(256, 61, 299, 132);
        pane.add(lblMainIcon);

        // 添加背景图片
        JLabel bkLabel = new JLabel("bk");
        bkLabel.setIcon(new ImageIcon(FirstView.class.getResource("/image/guanka.png")));
        bkLabel.setBounds(5, 5, 790, 600);
        pane.add(bkLabel);


        frame.setVisible(true);
    }


    public static void main(String[] args) {
        FirstView fv = new FirstView();
    }
}
